#@laybase() 
#define main()

#@orderProgress()
<div style="margin-top: 15px;position: relative;">
	<div class="col-md-3">
	#setLocal(tabs=["-","运营商","产品","日期","姓名","进度"])
	#setLocal(attrs=["owner","Operator","product","date","name","step"])
	#@dataTable(tabs,attrs,orderList,"/admin/photoReview")
	</div>
	#@datashowbox()
	<div class="col-md-6" >
		<div style="height: 692px;overflow: hidden;position: relative;display: none;" id="databox">
			<div id="databar" class="barbox">
				<div class="bar"></div>
			</div>
<style>
	#datalist .fileuploadul h4{
		position: relative;
	}
	
	#datalist .fileuploadul h4 label{
		position: absolute;
		top: 5px;
		right: 6px;
	}
	
	#datalist .fileuploadul h4 label p{
		padding: 4px 12px;
	}
	
	#datalist .fileuploadul h4 span {
		 font-size: 14px;
	}
	
	#datalist .fileuploadul .filebox{
		position: relative;
		overflow: hidden;
	}
	
	#datalist .fileuploadul .filebox .preview{
	    width: 177px;
	    height: 170px;
	    padding: 10px;
	    float: left;
	    position: relative;
	    border: 1px solid #fff;
	    border-radius: 5px;
	    cursor: pointer;
	}
	
	#datalist .fileuploadul .filebox .preview:hover {
	    background-color: #f1f7fd;
	    border-color: #b8d6fb;
	}
	
	#datalist .fileuploadul .filebox .preview .progress{
		width: 0;
		height: 10px;
		border-radius: 6px;
		background-color: #337ab7;
		position: absolute;
		bottom: 0;
		left: 0;
		margin: 0;
	}
	
	#datalist .fileuploadul .filebox .preview .imgbox{
		position: relative;
		height: 125px;
	}
	
	#datalist .fileuploadul .filebox .preview .imgbox.icon{
		text-align: center;
	}
	
	#datalist .fileuploadul .filebox .preview p{
		text-align: center;
	}
	
	#datalist .fileuploadul .filebox .preview p span.glyphicon {
    	color: #d9534f;
    	padding: 0 2px;
    	top: -2px;
	}
	
	#datalist .fileuploadul .filebox .preview p span.del {
		cursor: pointer;
	}
	
	#datalist .fileuploadul .filebox .preview p span.name {
		display: inline-block;
		width: 78%;
		overflow: hidden;
    	text-overflow: ellipsis;
    	white-space: nowrap;
	}
	
	#datalist .fileuploadul .filebox .preview .imgbox img{
		position: absolute;
	}
	
	#datalist .fileuploadul .filebox .tipbox{
		display: none;
		position: absolute;
		width: 100%;
		top: 0;
		left: 0;
		z-index: 2;
	}
	
	#datalist .fileuploadul button.btn{
		display: none;
	}
	#message-text::-webkit-input-placeholder{color: #fd0421;}
	
	#datalist .fileuploadul .filebox .preview .imgbox .iconfont {
		line-height: 105px;
		font-size: 70px;
		color: #508b37;
	}
	
	.css3loadingbox .line-spin-fade-loader>div {
		background-color: #fff;
	}
	
</style>
			<div id="datalist">
				
			</div>
			<!-- 视频上传 -->
			 <!-- <form id='spFrom' action='admin/uploadVideo' method='post' enctype='multipart/form-data'>
				<div class='fileuploadul' data-paramtername='sp' data-maxnum='10' data-minup='1' tipname='视频资料上传'>
					<h4 style='cursor: auto;'>面签视频资料上传
						<label>
						 <p class='btn btn-primary'  id='gitspTip'>选择视频</p>
						 <span class='filenownum'></span>
						 <input id='gitsp' type='file' name='faceSign' class='upimg-hook' accept='video/mp4,video/mpeg,video/mpeg' multiple style='display: none;'>
						</label>
					</h4>
					<div class='filebox'>
					<div id='video' class='w50'></div>
					</div>
				 </div>
			</form> -->
		</div>
	</div>
	<div class="col-md-3 scrollbox" style="display: none;">
		<select id="selectphoto" class="form-control"></select>
		<div id="pageContent">
			
		</div>
	</div>
</div>
<div id="loginModal" class="modal" style="display:none">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" onclick="$('#loginModal').modal('hide')">x</button>
				<h1 class="text-center text-primary">选择生成项</h1>
			</div>
			<div class="modal-body" style="overflow: hidden;">
				<form id="exportForm" action="#" class="form col-md-12 center-block" onsubmit="return false">
					<div class="form-group" id="exportContent">
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
<!-- 生产合同后的弹框 -->
<style>
#bargaincallback{
	width: 600px;
	margin: 0;
	position: fixed;
	top: -2%;
	left: 50%;
	margin-left: -300px;
	display: none;
	z-index: 2;
}

#bargaincallback .callbacklist{
	overflow: auto;
	max-height: 80vh;
	margin: 0;
}

#bargaincallback .callbacklist li span{
	vertical-align: text-top;
	color: #00cc33;
}
#bargaincallback .callbacklist li span.glyphicon-remove{
	color: #db4d70;
}
</style>
<div class="modal-dialog" id="bargaincallback">
	<div class="modal-content">
		<div class="modal-header"></div>
		<div class="modal-body" style="max-height: 765px;overflow: auto;">
			<ul class="callbacklist"></ul>
			<div style="text-align: center;margin: 10px 0;"><button type="button" class="btn btn-primary">确定</button></div>
		</div>
	</div>
</div>
<script src="/assets/js/area.js"></script>
<script src="/assets/js/jquery.form.js"></script>

<script>
	$(function(){
		var ulnav = $("#nav-pills"),
			dataDom = $("#datalist"),
			//滚动条
			boxDom = $('#databox'),
			barbox = $('#databar'),
			datashowbox = $("#datashowbox"),//数据统计
			databox = $("#databox"),//数据展示层
			$select = $("#selectphoto"),
			OPT = ""
		
		//选择下拉列表更换图片
		$select.on("change",function(){
			createImg($(this).val());
		});	
		
		//初始化图片放大
		function createImg(src){
			var image = new Image()
			image.src = src
			image.onload = function(){
				var dom = $("<div></div>")
				dom.css({
					width: $("#pageContent").parent().width(),
					height: 450
				})
				dom.iviewer({
	                src: this.src
	            });
				$("#pageContent").html(dom)
			}
			image.onerror = function(){
				$("#pageContent").html("")
				_x.show_alert_sh("找不到图片！",false)
			}
		}
	
		/*datashowbox.find("select").change(function(){
			var orderId = $(this).val();
			$.getJSON("/admin/getJson",{type:4,orderId:orderId},function(data){
				datashowbox.hide();
		    	databox.show();
		    	console.log(data)
		    	getBaseTab(data,showSuc)
		    	dataDom.css("top",0);
		    	_x.scrollBar.init({
					boxDom:boxDom,
					barbox:barbox,
					content:dataDom
				})
			})
		})*/
		
		function getJson(type,orderId){
			var params = {
				params: {
					type:type,
					orderId:orderId
				}
			}
			return axios.get("/admin/getJson",params)
		}
		
		$("#rtable").on("click","tbody tr",function(){
			if($(this).hasClass("sel"))return;
			var orderId = $(this).data("orderid");
			$(this).addClass("sel").siblings("tr").removeClass("sel");
			$("#meansp,#err,#ok").hide();
			axios.all([getJson(4,orderId),getJson(7,orderId)])
			.then(axios.spread(function(json1,json2){
				OPT = json2.data.opt
				datashowbox.hide().siblings(".scrollbox").show();
		    	databox.show();
		    	console.log(json1.data)
		    	//console.log(json2.data)
		    	getBaseTab(json1.data,json2.data,showSuc)
		    	dataDom.css("top",0);
		    	_x.scrollBar.init({
					boxDom:boxDom,
					barbox:barbox,
					content:dataDom
				})
				_com.addMsg(databox,json2.data)
				axios.get("/admin/getAllStates")
				.then(function(progress){
					_com.renderOrderProgress(progress.data)
				})
			}))
			
			
			
		})
		
		//渲染完毕添加省市
		function showSuc(){
			var areaInput = $("#bargainLoan_area"),
				areaVal = areaInput.val().split(","),//过滤省市
				preIndex = XXarea.presMap[areaVal[0]],
				cityIndex = -1,
				presDom = $("#area_pres"),
				citysDom = $("#area_citys"),
				pres = "",
				khdInput = $("#bargainLoan_bankArea"),
				khdVal = khdInput.val().split(","),//过滤省市
				preIndex2 = XXarea.presMap[khdVal[0]],
				khdPresDom = $("#bankArea_pres"),
				khdCitysDom = $("#bankArea_citys"),
				cityIndex2 = -1,
				pres2 = ""
			
			if(khdVal.length > 1){//开户地默认选中已有数据
				cityIndex2 = XXarea.citysMap[khdVal[1]];
				var citys = "",
					citysArr = XXarea.citys[preIndex2];
				for(var i = 0;i < citysArr.length;i++){
					if(i == cityIndex2){
						citys += "<option value='"+ citysArr[i] +"' selected='selected'>"+ citysArr[i] +"</option>";
					}else{
						citys += "<option value='"+ citysArr[i] +"'>"+ citysArr[i] +"</option>";
					}
				}
				khdCitysDom.append(citys);
			}

			if(areaVal.length > 1){//默认选中已有数据
				cityIndex = XXarea.citysMap[areaVal[1]];
				var citys = "",
					citysArr = XXarea.citys[preIndex];
				for(var i = 0;i < citysArr.length;i++){
					if(i == cityIndex){
						citys += "<option value='"+ citysArr[i] +"' selected='selected'>"+ citysArr[i] +"</option>";
					}else{
						citys += "<option value='"+ citysArr[i] +"'>"+ citysArr[i] +"</option>";
					}
				}
				citysDom.append(citys);
			}
			
			//初始化数据，如果有就添加默认选中
			for(var i = 0;i < XXarea.pres.length;i++){
				if(i == preIndex){
					pres += "<option value='"+ XXarea.pres[i] +"' selected='selected'>"+ XXarea.pres[i] +"</option>";
				}else{
					pres += "<option value='"+ XXarea.pres[i] +"'>"+ XXarea.pres[i] +"</option>";
				}
			}
			presDom.append(pres);
			
			//开户地初始化数据，如果有就添加默认选中
			for(var i = 0;i < XXarea.pres.length;i++){
				if(i == preIndex2){
					pres2 += "<option value='"+ XXarea.pres[i] +"' selected='selected'>"+ XXarea.pres[i] +"</option>";
				}else{
					pres2 += "<option value='"+ XXarea.pres[i] +"'>"+ XXarea.pres[i] +"</option>";
				}
			}
			khdPresDom.append(pres2);
			
			presDom[0].onchange = function(){
				var val = this.value,	
					citys = "<option value='-1'>--请选择--</option>";
				if(val != -1){//添加城市
					var index = XXarea.presMap[val];
					for(var i = 0;i < XXarea.citys[index].length;i++){
						citys += "<option value='"+ XXarea.citys[index][i] +"'>"+ XXarea.citys[index][i] +"</option>";
					}
					citysDom.html(citys);
					areaInput.val(val).addClass("submit-hook");
				}else{
					citysDom.html(citys);
					areaInput.val("").addClass("submit-hook");
				}
			}
			
			citysDom[0].onchange = function(){
				var val = this.value;
				if(val != -1){
					areaInput.val(presDom.val() +","+ val).addClass("submit-hook");
				}else{
					areaInput.val(presDom.val()).addClass("submit-hook");
				}
			}
			
			khdPresDom[0].onchange = function(){
				var val = this.value,	
					citys = "<option value='-1'>--请选择--</option>";
				if(val != -1){//添加城市
					var index = XXarea.presMap[val];
					for(var i = 0;i < XXarea.citys[index].length;i++){
						citys += "<option value='"+ XXarea.citys[index][i] +"'>"+ XXarea.citys[index][i] +"</option>";
					}
					khdCitysDom.html(citys);
					khdInput.val(val).addClass("submit-hook");
				}else{
					khdCitysDom.html(citys);
					khdInput.val("").addClass("submit-hook");
				}
			}
			
			khdCitysDom[0].onchange = function(){
				var val = this.value;
				if(val != -1){
					khdInput.val(khdPresDom.val() +","+ val).addClass("submit-hook");
				}else{
					khdInput.val(khdPresDom.val()).addClass("submit-hook");
				}
			}
		}
		
		
		function getBaseTab(data,data2,callback){
			dataDom.html("");
			var uploadHtml = "<div class='fileuploadul' data-paramtername='lxr' data-maxnum='10' data-minup='1' tipname='电信、移动、联通'>"+
							 "   <h4 style='cursor: auto;'>借款人的联系人资料"+
							 "		<a href='http://www.189.cn/' target='_blank'>电信</a>"+
							 "		<a href='http://www.10086.cn/' target='_blank'>移动</a>"+
							 "		<a href='http://www.10010.com/' target='_blank'>联通</a>"+
							 "	<label>"+
							 "		<p class='btn btn-primary'>选择图片</p>"+
							 "		<span class='filenownum'></span>"+
							 "		<input type='file' name='zxcx' class='upimg-hook' accept='image/png, image/gif, image/jpg, image/jpeg' multiple style='display: none;'>"+
							 "	</label>"+
						     "	</h4>"+
						     "	<div class='filebox'>"+
						     "		<div class='tipbox alert alert-danger'></div>"+
						     "	</div>"+
						     "	<button id='uploadbtn' class='btn btn-default btn-sm dropdown-toggle' type='button'>开始上传</button>"+
					         "</div>"+
					         "<div class='fileuploadul' data-paramtername='fyb' data-maxnum='10' data-minup='1' tipname='复议表'>"+
							 "   <h4 style='cursor: auto;'>复议表"+
							 "	<label>"+
							 "		<p class='btn btn-primary'>选择图片</p>"+
							 "		<span class='filenownum'></span>"+
							 "		<input type='file' name='fyb' class='upimg-hook' accept='image/png, image/gif, image/jpg, image/jpeg' multiple style='display: none;'>"+
							 "	</label>"+
						     "	</h4>"+
						     "	<div class='filebox'>"+
						     "		<div class='tipbox alert alert-danger'></div>"+
						     "	</div>"+
						     "	<button id='uploadbtn' class='btn btn-default btn-sm dropdown-toggle' type='button'>开始上传</button>"+
					         "</div>"+
					         "<div class='fileuploadul' data-paramtername='spb' data-maxnum='10' data-minup='1' tipname='营业部审批表'>"+
							 "   <h4 style='cursor: auto;'>营业部审批表"+
							 "	<label>"+
							 "		<p class='btn btn-primary'>选择图片</p>"+
							 "		<span class='filenownum'></span>"+
							 "		<input type='file' name='spb' class='upimg-hook' accept='image/png, image/gif, image/jpg, image/jpeg' multiple style='display: none;'>"+
							 "	</label>"+
						     "	</h4>"+
						     "	<div class='filebox'>"+
						     "		<div class='tipbox alert alert-danger'></div>"+
						     "	</div>"+
						     "	<button id='uploadbtn' class='btn btn-default btn-sm dropdown-toggle' type='button'>开始上传</button>"+
					         "</div>";
					         
			if(OPT === "苏宁"){
				uploadHtml += "<div class='fileuploadul' data-paramtername='hkqr' data-maxnum='10' data-minup='1' tipname='还款确认表'>"+
							  "   <h4 style='cursor: auto;'>还款确认表"+
							  "	<label>"+
							  "		<p class='btn btn-primary'>选择文件</p>"+
							  "		<span class='filenownum'></span>"+
							  "		<input type='file' name='hkqr' accept='' class='uptext-hook' multiple style='display: none;'>"+
							  "	</label>"+
						      "	</h4>"+
						      "	<div class='filebox'>"+
						      "		<div class='tipbox alert alert-danger'></div>"+
						      "	</div>"+
						      "	<button id='uploadbtn' class='btn btn-default btn-sm dropdown-toggle' type='button'>开始上传</button>"+
					          "</div>";
			}
			var spHTML = '';
			if(data.upfiles.length>0){
				spHTML = "<form id='spFrom' action='/admin/uploadVideo' method='post' enctype='multipart/form-data'>"+
						 "<div class='fileuploadul' data-paramtername='faceSign' data-maxnum='10' data-minup='1' tipname='视频资料上传'>"+
						 "   <h4 style='cursor: auto;'>面签视频资料上传"+
						 "	<label>"+
						 "		<p class='btn btn-primary'>选择视频</p>"+
						 "		<span class='filenownum'></span>"+
						 "		<input id='gitsp' type='file' name='faceSign' class='upimg-hook' accept='video/mp4,video/mpeg,video/mpeg' multiple style='display: none;'>"+
						 "	</label>"+
					     "	</h4>"+
					     "	<div class='filebox'>"+
						 "		<div id='video' class=''>"+
						 "			<video src='"+data.upfiles[0].src[0]+"'controls='controls' width='300' height='200'></video>"+
						 "		</div>"+
						 "	</div>"+
				         "</div>"+
					     "</form>"; 
			}else{
				spHTML = "<form id='spFrom' action='/admin/uploadVideo' method='post' enctype='multipart/form-data'>"+
						 "<div class='fileuploadul' data-paramtername='faceSign' data-maxnum='10' data-minup='1' tipname='视频资料上传'>"+
						 "   <h4 style='cursor: auto;'>面签视频资料上传"+
						 "	<label>"+
						 "		<p class='btn btn-primary'>选择视频</p>"+
						 "		<span class='filenownum'></span>"+
						 "		<input id='gitsp' type='file' name='faceSign' class='upimg-hook' accept='video/mp4,video/mpeg,video/mpeg' multiple style='display: none;'>"+
						 "	</label>"+
					     "	</h4>"+
					     "	<div class='filebox'>"+
						 "		<div id='video' class=''></div>"+
						 "	</div>"+
				         "</div>"+
					     "</form>"; 
			}
			
			 uploadHtml += spHTML; 
			//添加照片
			var photosel = $("#selectphoto"),
				options = "",
				photoLen = data.photo.length;
			if(photoLen > 0){
				createImg(data.photo[0].src);
				$("#pageContent").css("height",450);
			}else{
				$("#pageContent").css("height",0);
			}
			for(var i = 0;i < photoLen;i++){
				options += "<option value='"+ data.photo[i].src +"'>"+ data.photo[i].exp +"</option>";
			}
			photosel.html(options);
			
			//添加视频
			/* var video = data.upfiles[0];
			console.log(video.src[0]);
			console.log( $('#video') );
			var videoHTML = `<video src="${video.src[0]}" controls="controls" width='300' height='200'></video>`;
			$('#video').html(videoHTML); */
			
			
			
			//添加表单
			for(var i = 0; i < data.tabList.length; i++){
				var content = data.tabList[i].content,
					tab = data.tabList[i].tab,
					tabDom = $("<h4 data-toggle='collapse' href='#"+ content +"'>"+ tab +"</h4>"),
					contentDom = $("<div id='"+ content +"' class='collapse'></div>"),
					formbox = $("<div style='overflow: hidden;'></div>");
				dataDom.append(tabDom).append(contentDom);
				contentDom.append(formbox);
				for(var j = 0;j < data.dataList[content].length;j++){
					var that = data.dataList[content][j],
						html = "",
						iputType = that.iputType,
						val = that.value,
						paramterName = "bargainLoan." + that.paramterName,
						title = that.zhExpl,
						unit = that.unit,
						unitHtml = "",
						len = that.length,
						selectValue = that.selectValue,
						readonly = "",
						yzCls = "yz"
					if(that.defaultState == "1"){
						readonly = "readonly='true'"
						yzCls = ""
					}
					if(_x.isEmpty(len)){
						len = "";
					}else{
						len = "data-len='"+ len +"'";
					}
					if(_x.isEmpty(val)){
						val = "";
					}
					if(!_x.isEmpty(unit)){
						unitHtml = "<div class='input-group-addon'>"+ unit +"</div>";
					}
					if(_x.isEmpty(selectValue)){
						var input = "<input type='text' "+ readonly +" class='form-control "+ yzCls +"' id='"+ paramterName +"' name='"+ paramterName +"' value='"+ val +"' "+ len +">";
						if(iputType == "number"){
							input = "<input type='text' "+ readonly +"  class='number form-control "+ yzCls +"' id='"+ paramterName +"' name='"+ paramterName +"' value='"+ val +"' "+ len +">";
						}else if(iputType == "date"){
							input = "<input type='text' "+ readonly +"  class='date form-control "+ yzCls +"' id='"+ paramterName +"' name='"+ paramterName +"' readonly='true' value='"+ val +"' "+ len +" >";
						}else if(iputType == "area"){
							input = "<input type='hidden' "+ readonly +"  class='date form-control "+ yzCls +"' id='bargainLoan_"+ that.paramterName +"' name='"+ paramterName +"' value='"+ val +"' "+ len +" >";
							input += "<select id='"+ that.paramterName +"_pres' class='form-control precitysel' style='width: 50%;'><option value='-1'>--请选择--</option></select><select id='"+ that.paramterName +"_citys' class='form-control precitysel' style='width: 50%;margin-left: -1px;'><option value='-1'>--请选择--</option></select>";
						}
						html = "<div class='form-group col-md-6'>"+
							   "	<div class='input-group'>"+
							   "		<label class='input-group-addon' for='"+ paramterName +"'>"+ title +"</label>"+
							   			input+
							   			unitHtml+
							   "	</div>"+
							   "</div>";
					}else{
						var selHtml = "<select name='"+ paramterName +"' id='"+ paramterName +"' class='form-control "+ yzCls +"'>",
							selData = selectValue.split(",");
						for(var k = 0;k < selData.length;k++){
							if(val == selData[k]){
								selHtml += "<option value='"+ val +"' selected='selected'>"+ val +"</option>";
							}else{
								selHtml += "<option value='"+ selData[k] +"'>"+ selData[k] +"</option>";
							}
						}
						selHtml += "</select>";
						html = "<div class='form-group col-md-6'>"+
							   "	<div class='input-group'>"+
							   "		<label class='input-group-addon' for='"+ paramterName +"'>"+ title +"</label>"+
							   		selHtml+
							   		unitHtml+
							   "	</div>"+
							   "</div>";
					}
					formbox.append(html);
				}
				contentDom.append("<button type='button' class='btn btn-primary' style='padding: 8px 30px;' id='save_"+ content +"' data-loading-text='请稍后...'>保存</button>");
				if(tab == "联系人信息"){
					contentDom.append("<button type='button' class='btn btn-primary' style='padding: 8px 30px;margin-left: 15px;' id='get_contract' data-loading-text='请稍后...'>生成合同</button>");
					contentDom.append("<button type='button' class='btn btn-primary' style='padding: 8px 30px;margin-left: 15px;' id='downLoad' data-loading-text='请稍后...'>下载合同</button>");
				}
				if(tab == "其他信息"){
					contentDom.append("<button type='button' class='btn btn-primary' style='padding: 8px 30px;margin-left: 15px;' id='createExcel' data-loading-text='请稍后...'>生成表单</button>");
					contentDom.append("<button type='button' class='btn btn-primary' style='padding: 8px 30px;margin-left: 15px;' id='downLoadExcel' data-loading-text='请稍后...'>下载表单</button>");
					contentDom.append("<button type='button' class='btn btn-success' style='padding: 8px 30px;margin-left: 15px;' id='tongguo' data-loading-text='请稍后...'>通过</button>");
				}
				contentDom.on('click','#save_' + content,save);
				if(dataDom.children(".collapse").length == data.tabList.length){
					callback();
				}
			}
			
			dataDom.append(uploadHtml);
			
			//添加照片
			if(!_x.isEmptyObj(data2.lxr)){//联系人（通话记录）
				imgShow("lxr",data2.lxr,true);
			}
			
			if(!_x.isEmptyObj(data2.fyb)){//复议表
				imgShow("fyb",data2.fyb,true);
			}
			
			if(!_x.isEmptyObj(data2.spb)){//营业部审批表
				imgShow("spb",data2.spb,true);
			}
			
			 if(!_x.isEmptyObj(data2.sp)){//sp
				imgShow("sp",data2.sp,true);
			} 
			
			if(OPT === "苏宁" && !_x.isEmptyObj(data2.hkqr)){//营业部审批表
				imgShow("hkqr",data2.hkqr,false);
			}
		}
		
		function imgShow(paramtername,dataArr,isImage){
			var i = 0,
				phtHtml = "",
				len = dataArr.length;
			var digui = function(){
				var image = new Image();
				image.src = dataArr[i];
				if(i >= len){
					dataDom.find("div[data-paramtername='"+ paramtername +"']").find(".filebox").html("<div class='tipbox alert alert-danger' role='alert'></div>" + phtHtml);
					//刷新滚条
					_x.scrollBar.init({
						boxDom:boxDom,
						barbox:barbox,
						content:dataDom
					})
				}else{
					image.onload = function(){
						var imgData = _x.imgFormat(this.width,this.height,155,125),
							name = decodeURI(this.src.substring(this.src.lastIndexOf("/") + 1));
						phtHtml += "<div class='preview yes formserver'>"+
								   "	<div class='imgbox'>"+
								   "		<img data-src='"+ this.src +"' src='"+ this.src +"' style='width: "+ imgData.imgWidth +"px;height: "+ imgData.imgHeight +"px;top: "+ ((125 - imgData.imgHeight) / 2) +"px;left: "+ ((155 - imgData.imgWidth) / 2) +"px;' />"+
								   "	</div>"+
								   "	<p><span class='name'>"+ name +"</span></p>"+
								   "</div>";
						i++;
						digui();
					}
				}
			}
			
			var readEcxel = function(){
				for(var k = 0;k < dataArr.length;k++){
					var name = decodeURI(dataArr[k].substring(dataArr[k].lastIndexOf("/") + 1));
					phtHtml += "<div class='preview yes formserver excel-hook'>"+
							   "	<div class='imgbox icon'>"+
							   "		<i class='iconfont xlsx' data-src='"+ dataArr[k] +"'>&#xe605;</i>"+
							   "	</div>"+
							   "	<p><span class='name'>"+ name +"</span></p>"+
							   "</div>";
					if(k === dataArr.length - 1){
						dataDom.find("div[data-paramtername='"+ paramtername +"']").find(".filebox").html("<div class='tipbox alert alert-danger' role='alert'></div>" + phtHtml);
						//刷新滚条
						_x.scrollBar.init({
							boxDom:boxDom,
							barbox:barbox,
							content:dataDom
						})
					}
				}
			}
			
			if(isImage){
				digui()
			}else{
				readEcxel()
			}
		}
		
		var createBargain = $("#createBargain"),//进度条层
			bargaincallback = $("#bargaincallback");//生成合同后显示
		bargaincallback.find("button").click(function(){
			bargaincallback.fadeOut(300);
		})
		function showDialog(data,actionKey){
			$content = $("#exportContent")
			//全选目录
			var contentStr = "<div class='checkbox'>"+
								"<label>"+
									"<input id='selectAll' checked='true' type='checkbox'>全选/反选"
								"</label>"+
							"</div>";
			//文件选择目录
			var dataList = data.dataList,
				length = dataList.length,
				tabList = data.tabList;
			for (var i = 0; i < length; i++) {
				var tab = tabList[i],
					tdata = dataList[i],
					tlength = tdata.length,
					str = "";
				if(tlength > 1){
					str += "<div class='checkbox'>"+
				      			"<input class='tabsetCheck' checked='true' type='checkbox' style='margin-left:0px;'>"+
				    			"<label data-toggle='collapse' href='#scoll"+i+"'>"+tab+"</label>"+
				  			"</div>";
				  	str += "<div class='checkbox collapse' id='scoll"+i+"' style='margin-left:20px;'>"
				  	for(var j = 0;j < tlength; j++){
				  		var edata = tdata[j];
				  		str += "<div>"+
				  					"<label>"+
					      				"<input checked='true' type='checkbox' name='"+edata.name+"' value='sure'>"+edata.name+
					    			"</label>"+
					    		"</div>";
				  	}
				  	str += "</div>"
				}else if(tlength == 1){
					var edata = tdata[0];
					str += "<div class='checkbox'>"+
				    			"<label>"+
				    				"<input checked='true' type='checkbox' name='"+edata.name+"' value='sure'>"+edata.name+
				    			"</label>"+
				  			"</div>";
				}
			  	contentStr = contentStr+str;
			}
			//确定按钮
			contentStr = contentStr+"<button class='btn btn-primary' id='sureBtn'>确定</button>";
			$content.html(contentStr);
			$("#loginModal").css("display","");
			$("#loginModal").modal("show");
			$all = $("#selectAll")
			$all.on("click",function(){
				if (!$all.prop("checked")) {
					$content.find("input").prop("checked",false)
				}else{
					$content.find("input").prop("checked",true)
				}
			})
			$tabsetCheck = $(".tabsetCheck")
			$tabsetCheck.on("click",function(){
				var $target = $(this),
					$drop = $($target.siblings("label").attr("href"));
				if (!$target.prop("checked")) {
					$drop.find("input").prop("checked",false)
				}else{
					$drop.find("input").prop("checked",true)
				}
			})
			$surebtn = $("#sureBtn")
			$surebtn.on("click",function(){
				$('#loginModal').modal('hide')
				var formData = $("#exportForm").serialize();
				if (actionKey.indexOf("/admin/exportbargain")!=-1) {
					createBargain.fadeIn(300);//进度条显示
					createBargain.find(".progress-bar").addClass("active");
					$.ajax({
						type:"post",
						url:actionKey,
						data:formData,
						success:function(data){
							//console.log(data)
							createBargain.fadeOut(300);//进度条显示
							createBargain.find(".progress-bar").removeClass("active");
							
							bargaincallback.find(".modal-header").html("成功"+ data.succesed +"个，失败"+ data.failed +"个");
							var lihtml = "";
							//成功
							for(var i = 0;i < data.successList.length;i++){
								lihtml += "<li><span type='ok' class='glyphicon glyphicon-ok'></span>"+ data.successList[i] +"</li>";
							}
							
							//失败
							for(var i = 0;i < data.failList.length;i++){
								lihtml += "<li><span type='err' class='glyphicon glyphicon-remove'></span>"+ data.failList[i] +"</li>";
							}
							bargaincallback.fadeIn(300).find(".callbacklist").html(lihtml);
						}
					})
				}else{
					$.ajax({
						type:"post",
						url:actionKey,
						data:formData,
						success:function(data){
							if(data.code&&data.code==0){
								alert(data.msg);
							}else{
								location.href = data.msg;
							}
						}
					})
				}
			})
		}
		
		//出合同findExportList
		dataDom.on("click","#get_contract",function(){
			var $btn = $(this).button('loading')
			$.ajax({
				type:"post",
				url:"/admin/findExportList/1-3",
				success:function(data){
					if(data.code == 0){
						$btn.button('reset')
						_x.show_alert_sh(data.msg,false)
					}else{
						showDialog(data,"/admin/exportbargain/bargainReview")
						$btn.button('reset')
					}
				},
				error:function(){
					_x.show_alert_sh("您的网络异常，请稍后重试！",false)
					$btn.button('reset')
				}
			})
		})
		
		//下载合同 downLoad
		dataDom.on("click","#downLoad",function(){
			var $btn = $(this).button('loading')
			$.ajax({
				type:"post",
				url:"/admin/findExportList/1-3",
				success:function(data){
					if(data.code == 0){
						_x.show_alert_sh(data.msg,false)
					}else{
						showDialog(data,"/admin/downLoad")
						//console.log(data)
					}
					$btn.button('reset')
				},
				error:function(){
					$btn.button('reset')
					_x.show_alert_sh("您的网络异常，请稍后重试！",false)
				}
			})
		})
		
		//出合同findExportList
		dataDom.on("click","#createExcel",function(){
			var $btn = $(this).button('loading')
			$.ajax({
				type:"post",
				url:"/admin/findExportList/4-5",
				success:function(data){
					if(data.code == 0){
						//_x.show_alert_sh(data.msg,false)
					}else{
						//_x.show_alert_sh(data.msg,false)
						showDialog(data,"/admin/exportbargain")
						//console.log(data)
					}
					$btn.button('reset')
				},
				error:function(){
					$btn.button('reset')
					_x.show_alert_sh("您的网络异常，请稍后重试！",false)
				}
			})
		})
		
		//下载合同 downLoad
		dataDom.on("click","#downLoadExcel",function(){
			var $btn = $(this).button('loading')
			$.ajax({
				type:"post",
				url:"/admin/findExportList/4-5",
				success:function(data){
					if(data.code == 0){
						//_x.show_alert_sh(data.msg,false)
					}else{
						//_x.show_alert_sh(data.msg,true)
						showDialog(data,"/admin/downLoad")
						//console.log(data)
					}
					$btn.button('reset')
				},
				error:function(){
					$btn.button('reset')
					_x.show_alert_sh("您的网络异常，请稍后重试！",false)
				}
			})
		})
		
		//点击保存
		function save(){
			var $btn = $(this),
				yzDoms = $btn.parent().find(".yz"),
				mark = yanzheng(yzDoms);
			if(mark){
				yzDoms.removeClass("submit-hook")
				$btn.button('loading')
				var data = {};
				yzDoms.each(function(){
					var that = $(this);
					data[that.attr("name")] = that.val();
				})
				
				axios.post("/admin/fixBargainInfo",_x.qsStringify(data))
				.then(function(res){
					if(res.data.code == 1){
						_x.show_alert_sh(res.data.msg,true)
					}else{
						_x.show_alert_sh(res.data.msg,false)
					}
					$btn.button('reset')
				})
				.catch(function(){
					$btn.button('reset')
					_x.show_alert_sh("您的网络异常，请稍后重试！",false)
				})
			}
		}
		
		//表单验证
		function yanzheng(yzDoms){
			var mark = true;
			yzDoms.each(function(){
				var that = $(this),
					val = that.val();
				if(_x.isEmpty(val)){//空判断
					mark = false;
					that.attr("placeholder","此项不能为空！");
					that.parents(".form-group").addClass("has-error");
				}else if(!_x.isEmpty(that.data("len")) && val.length != that.data("len")){
					mark = false;
					that.attr("placeholder","长度必须为"+ that.data("len") +"位");
					that.parents(".form-group").addClass("has-error");
				}else if(that.hasClass("number") && isNaN(+val)){
					mark = false;
					that.attr("placeholder","请输入数字！");
					that.parents(".form-group").addClass("has-error");
				}else if((that.hasClass("precitysel") && val == -1) || (that.hasClass("precitysel") && that.siblings(".precitysel").val() == -1)){
					//判断是否选择省市
					mark = false;
					that.parents(".form-group").addClass("has-error");
				}else{
					that.parents(".form-group").removeClass("has-error");
				}
			})
			return mark;
		}
		
		//修改过的添加submit-hook,用于总提交
		dataDom.on("change",".yz",function(){
			$(this).addClass("submit-hook")
		})
		
		//失去焦点验证
		dataDom.on("blur",".yz",function(){
			yanzheng($(this));
		})
		
		//绑定日历
		dataDom.on("click",".date",laydate);
		
		//滚动条
		_x.scrollBar.init({
			boxDom:boxDom,
			barbox:barbox,
			content:dataDom
		})
		
		dataDom.on("shown.bs.collapse",".collapse", function () {
			_x.scrollBar.init({
				boxDom:boxDom,
				barbox:barbox,
				content:dataDom
			})
			var _top = $(this)[0].offsetTop,
				dd = $(this).prev("h4").outerHeight() + 15;
			if(dataDom.height() - _top <= boxDom.outerHeight() && dataDom.height() > boxDom.outerHeight()){
				_top = (dataDom.height() - boxDom.height() + dd+15)
				dataDom.animate({
					"top":-_top + dd
				},function(){
					var maxHeight = barbox.height() - barbox.children(".bar").height(),
						bit = Math.abs(dataDom[0].offsetTop) / dataDom.height(),
						$top = bit * barbox.height();
					if($top <= 0)$top = 0;
					if($top >= maxHeight)$top = maxHeight;
					barbox.children(".bar").css({"top":$top})
				})
			}
		})
		
		dataDom.on("hidden.bs.collapse",".collapse", function () {
			_x.scrollBar.init({
				boxDom:boxDom,
				barbox:barbox,
				content:dataDom
			})
			var _top = $(this).parent()[0].offsetTop,
				dd = $(this).prev("h4").outerHeight() / 2;
			if(dataDom.height() - Math.abs(_top) <= boxDom.outerHeight() && dataDom.height() > boxDom.outerHeight()){
				_top = (Math.abs(_top) + dd) - (boxDom.outerHeight() - (dataDom.height() - Math.abs(_top)));
				dataDom.animate({
					"top":-_top 
				},function(){
					var maxHeight = barbox.height() - barbox.children(".bar").height(),
						bit = Math.abs(dataDom[0].offsetTop) / dataDom.height(),
						$top = bit * barbox.height();
					if($top <= 0)$top = 0;
					if($top >= maxHeight)$top = maxHeight;
					barbox.children(".bar").css({"top":$top})
				})
			}else{
				dataDom.animate({
					"top":0
				})
			}
		})
		
		/* 图片上传 */
		//上传错误提示
		var timer = null;
		function fileTip(tipDom,txt){
			var fileBox = tipDom.parent()
			if(fileBox.height() <= 0){
				fileBox.css("height",52)
			}
			clearTimeout(timer);
			tipDom.show().text(txt);
			timer = setTimeout(function(){
				clearTimeout(timer);
				tipDom.fadeOut();
				fileBox.removeAttr("style")
			},2500)
		}
		
		//选择图片
		dataDom.on("change","input[type='file']:not([id='gitsp'])",function(){
			var that = $(this),
        		files = that[0].files,
        		liDom = that.parents(".fileuploadul"),
        		filebox = liDom.children(".filebox"),
        		tipbox = filebox.children(".tipbox");
        	if(files){
        		files = [].slice.call(files);
        		//验证图片大小和格式
        		for(var i = 0;i < files.length;i++){
        			if(files[i].size > 3145728){
        				if(files.length == 1){
        					that.val("");
        				}
        				fileTip(tipbox,"第"+ (i + 1) +"张图片大小超出限制，请上传3M以内的图片！")
        				files.splice(i,1);
        				i--;
        			}else if(that.hasClass("upimg-hook") && !_x.isImage(files[i].name.substring(files[i].name.lastIndexOf(".")))){
        				if(files.length == 1){
        					that.val("");
        				}
        				fileTip(tipbox,"第"+ (i + 1) +"张图片格式不正确，请上传.jpg/.jpeg/.png/.gif格式的图片！")
        				files.splice(i,1);
        				i--;
        			}else if(that.hasClass("uptext-hook") && (files[i].name.indexOf("xlsx") === -1 && files[i].name.indexOf("xls") === -1)){
        				if(files.length == 1){
        					that.val("");
        				}
        				fileTip(tipbox,"第"+ (i + 1) +"个文件格式不正确，请上传.xlsx/.xls格式的文件！")
        				files.splice(i,1);
        				i--;
        			}
        		}
        		
        		if(files.length == 0)return;
        		
        		//缓存files数组
        		liDom.data("files",files);
        		var allFilesNum = files.length + liDom.find(".yes").length;
        		
				//that.siblings("span").text("共"+ allFilesNum +"张图片");
        		if(files.length == 0)that.siblings("span").text("");
        		
				
				if(window.FileReader){
					filebox.children(".no").remove();
					if(that.hasClass("uptext-hook")){
						readImg(files,filebox,false);
					}else{
						readImg(files,filebox,true);//图片预览
					}
					
					liDom.children("button").show();
				}else{
					fileTip(tipbox,"您当前浏览器不支持图片预览功能！")
				}
				
        	}
		})
		
		//读取文件
		function readImg(files,appendDom,isImage){
			var html = "",
				i = 0,
				j = 0;
			var reapImg = function(){
				var file = files[i];
				if(file){
					var reader = new FileReader(),
						image = new Image();
					reader.onload = function(e){
						image.src = e.target.result;
						i++;
						reapImg();
					}
					reader.readAsDataURL(file);
					
					image.onload = function(){
						var imgData = _x.imgFormat(this.width,this.height,155,125);
						html = "<div class='preview no' filename='"+ file.name +"'>"+
								"	<div class='imgbox'>"+
								"		<img src='"+ this.src +"' data-src='"+ this.src +"' style='width: "+ imgData.imgWidth +"px;height: "+ imgData.imgHeight +"px;top: "+ ((125 - imgData.imgHeight) / 2) +"px;left: "+ ((155 - imgData.imgWidth) / 2) +"px;' />"+
								"	</div>"+
								"	<p><span class='name'>"+ file.name +"</span><span class='glyphicon glyphicon-remove del' data-index='"+ j +"'></span></p>"+
								"	<div class='progress' name='"+ file.name +"'></div>"+
								"</div>";
						appendDom.append(html)
						j++;
						//刷新滚动条
						_x.scrollBar.init({
							boxDom:boxDom,
							barbox:barbox,
							content:dataDom
						})
					}
				}
			}
			
			var readEcxel = function(){
				for(var k = 0;k < files.length;k++){
					//console.log(files[i])
					html += "<div class='preview no excel-hook' filename='"+ files[k].name +"'>"+
							"	<div class='imgbox icon'>"+
							"		<i class='iconfont xlsx' data-src='"+ files.path +"'>&#xe605;</i>"+
							"	</div>"+
							"	<p><span class='name'>"+ files[k].name +"</span><span class='glyphicon glyphicon-remove del' data-index='"+ j +"'></span></p>"+
							"	<div class='progress' name='"+ files[k].name +"'></div>"+
							"</div>";
				
				}
				appendDom.append(html)
				//刷新滚动条
				_x.scrollBar.init({
					boxDom:boxDom,
					barbox:barbox,
					content:dataDom
				})
			}
			
			if(isImage){
				reapImg()
			}else{
				readEcxel()
			}
		}
		
		//删除预览图
		dataDom.on("click","span.del",function(e){
			e.stopPropagation()
			del_local($(this),true)
		})
		
		function del_local(btnDom,isLocalDel){
			var liDom = btnDom.parents(".fileuploadul"),
				index = btnDom.data("index"),
				files = liDom.data("files");
				filenum = 0
				
			if(isLocalDel){
				btnDom.parents(".no").remove();
				files.splice(index,1,null);//删除并替换为空
				liDom.data("files",files);
				_x.show_alert_sh("删除成功！",true)
				/*for(var i = 0;i < files.length;i++){
					if(!_x.isEmpty(files[i])){
						filenum++;
					}
				}*/
			}else{
				btnDom.parents(".yes").remove();
			}
			
			if(liDom.find(".no").length === 0)liDom.children("button").hide();
			
			/*var allFilesNum = filenum + liDom.find(".yes").length;
			if(filenum == 0){
				liDom.children("button").hide();
				allFilesNum = "共"+ allFilesNum +"张图片";
				if(allFilesNum == 0)allFilesNum = "";
				liDom.children("h4").find("span.filenownum").text(allFilesNum);
			}else{
				liDom.children("h4").find("span.filenownum").text("共"+ allFilesNum +"张图片");
			}*/
			//刷新滚条
			_x.scrollBar.init({
				boxDom:boxDom,
				barbox:barbox,
				content:dataDom
			})
		}
		
		
		//点击上传
		var allLi = dataDom.children(".fileuploadul").children("li");
		dataDom.on("click","#uploadbtn",function(){
			var liDom = $(this).parent(),
				files = liDom.data("files"),
				paramterName = liDom.data("paramtername");
			//console.log(liDom.children("h4").text())	
			for(var i = 0;i < files.length;i++){
				if(!_x.isEmpty(files[i])){
					var xhr = new XMLHttpRequest(),
	                	formData = new FormData(),
	                	progressDom = liDom.find(".no[filename='"+ files[i].name +"']").children(".progress");
	            	formData.append(paramterName,files[i]);
	        		xhr.open("post","/admin/uploadEvalPho",true);
	        		xhr.progressDom = xhr.upload.progressDom = progressDom;
	        		xhr.addEventListener("load",function(){
	                    var result = JSON.parse(this.response);
	                    if(result.code == 1){
		                    //console.log("success--->"+result)
		                    this.progressDom.parents(".preview").find("img").data("src",result.src)
		                    this.progressDom.fadeOut(300).siblings("p").children(".glyphicon").removeClass("glyphicon-remove del").addClass("glyphicon-ok").css("color","#5cb85c");
		                    this.progressDom.parents(".preview").removeClass("no").addClass("yes").removeAttr("filename");
	                    }else{
	                    	this.progressDom.parents(".preview").remove()
	                    	_x.show_alert_sh(result.msg,false)
	                    }
	                });
	        		
	        		xhr.upload.addEventListener('progress',function(e){
	                    if(e.lengthComputable){//是否可以计算上传字节数
	                        var percent = e.loaded / e.total;                        
	                        this.progressDom.css("width",(percent * 100) + "%");
	                    };
	                });
	        		
	        		xhr.send(formData);
				}
			}
			liDom.children("button").hide();
			//刷新滚条
			_x.scrollBar.init({
				boxDom:boxDom,
				barbox:barbox,
				content:dataDom
			})
		})
		
		//图片预览
		var loadingHtml = "<div class='css3loadingbox' style='position: absolute;top: 50%;left: 50%;margin: -40px 0 0 -40px;'>"+
						  "    <div class='line-spin-fade-loader'>"+
						  "        <div></div>"+
						  "        <div></div>"+
						  "        <div></div>"+
						  "	       <div></div>"+
					 	  "	       <div></div>"+
						  "	       <div></div>"+
						  "	       <div></div>"+
						  "	       <div></div>"+
						  "    </div>"+
						  "</div>",
		    showimg = $("#showimg"),//背景层
			imgbox = showimg.children(".imgbox"),//可视区域
			imgboxW = imgbox.width(),
			imgboxH = imgbox.height(),
			imgul = imgbox.children("ul.imgul"),//图片容器
			confirm = $("#alert_confirm"),
			delbBtnDom = null;//缓存删除按钮
		showimg.removeAttr("style").hide().find("ul.btn").hide()
		showimg.find(".css3loadingbox").hide()
		function getImg(opt){
			var src = opt.src,
				title = opt.title,
				isLocalDel = opt.isLocalDel,
				delCls = "",
				liDom = $("<li class='active'></li>"),
				delIndex = opt.delIndex,
				isImage = opt.isImage;
				
			if(isLocalDel){
				delCls = "del-local-hook"//本地删除
			}
			
			if(!isImage){
				liDom.html("")
				showimg.find(".css3loadingbox").remove()
				var ovfl = $("<div style='width: 100%;height: 100%;overflow: hidden;position: relative;'></div>"),
					imgBox = $("<div class='imgdom text'>暂无预览</div>"),
					divDom = $("<div class='info'><p>"+ title +"</p><button class='btn btn-danger del-hook "+ delCls +"' data-src='"+ src +"' data-delindex='"+ delIndex +"'>删除</button></div>")
				ovfl.append(imgBox)
				liDom.append(ovfl).append(divDom);
			}else{
				liDom.html("")
				var dom = $("<div></div>"),
					divDom = $("<div class='info'><p>"+ title +"</p><button class='btn btn-danger del-hook "+ delCls +"' data-src='"+ src +"' data-delindex='"+ delIndex +"'>删除</button></div>")
					dom.css({
						width: imgboxW,
						height: imgboxH,
						position: "relative"
					})
					dom.iviewer({
	                     src: src
	                });
					liDom.append(divDom).append(dom)
			}
			imgul.html(liDom);
		}
		
		//点击展示
		dataDom.on("click",".preview",function(){
			var that = $(this)
				src = "",
				isImage = true
			
			if(that.hasClass("excel-hook")){
				if(that.hasClass("no"))return
				src = that.find("i.xlsx").data("src")
				src = src.substring(src.indexOf("fileSrc") - 1 )
				isImage = false
			}else{
				src = that.find("img").data("src")
				src = src.substring(src.indexOf("fileSrc") - 1 )
			}
				
			showimg.fadeIn(300);
			$('html').css("overflow","hidden")
			var option = {
				src: src,
				title: that.find("span.name").text(),
				isLocalDel: false,
				isImage: isImage
			}
			
			
			if(that.hasClass("no")){
				option.isLocalDel = true
				delbBtnDom = that.find("span.del")
			}else{
				delbBtnDom = that.find("p")
			}
			
			getImg(option)
		})
		
		//关闭图片展示
		showimg.on("click",function(e){
			$(this).fadeOut(300);
			$('html').removeAttr("style")
		})
		
		imgbox.on("click","img",function(e){
			e.stopPropagation();
		})
		
		showimg.on("click","div.iviewer_common",function(e){
			e.stopPropagation()
		})
		
		imgbox.on("click",function(e){
			e.stopPropagation();
		})
		
		//点击删除按钮
		imgul.on("click","button.del-hook",function(e){
			e.stopPropagation();
			var that = $(this),
				option = {
					isShowBg: false,
					text: "您真的要删除吗？",
					fn: function(modalDom,btn,callback){
						if(that.hasClass("del-local-hook")){
							del_local(delbBtnDom,true)
							showimg.fadeOut(300);
							$('html').removeAttr("style")
							_x.show_alert_sh("删除成功！",true)
							callback()
						}else{
							axios.get("/admin/deleteEvalPho",{
								params: {
									src: decodeURI(that.data("src"))
								}
							})
							.then(function(res){
								if(res.data.code == 1){
									_x.show_alert_sh("删除成功！",true)
									del_local(delbBtnDom,false)
									showimg.fadeOut(300);
									$('html').removeAttr("style")
									callback()
								}else{
									btn.button('reset')
									_x.show_alert_sh(res.data.msg,false)
								}
								
							})
							.catch(function(){
								btn.button('reset')
								_x.show_alert_sh("删除失败！",false)
							})
						}
					}
				}
			_x.show_alert_confirm(option)
		})
		
		dataDom.on("click","#tongguo",function(){
			var $btn = $(this),
				errDom = null
			dataDom.children(".fileuploadul").each(function(){
				var minUp = $(this).data("minup")
				if($(this).find("div.yes").length < minUp){
					errDom = $(this)
					return false
				}
			})
			
			if(errDom != null){
				_x.show_alert_sh("请上传"+ errDom.attr("tipname") +"！",false)
				return
			}
			
			var errDom2 = yanzheng2(dataDom.find(".yz"))
			if(errDom2 != null){
				_x.show_alert_sh("请输入"+ errDom2.parents(".collapse").prev("h4").text() +"-"+ errDom2.siblings("label").text() +"！",false)
				return
			}
			
			$btn.button('loading')
			
			//把没有保存的信息存入数据库
			var notSaveInput = dataDom.find(".submit-hook")
			if(notSaveInput.length > 0){
				var data = {};
				notSaveInput.each(function(){
					var that = $(this);
					data[that.attr("name")] = that.val();
				})
				
				axios.post("/admin/fixBargainInfo",_x.qsStringify(data))
				.then(function(res){
					if(res.data.code == 1){
						all_submit()
					}else{
						_x.show_alert_sh(res.data.msg,false)
						$btn.button('reset')
					}
					//console.log(res)
				})
				.catch(function(){
					$btn.button('reset')
					_x.show_alert_sh("您的网络异常，请稍后重试！",false)
				})
			}else{
				all_submit()
			}
			
			function all_submit(){
				axios.get("/admin/finishBargainReview")
				.then(function(res){
					$btn.button('reset')
					if(res.data.code == 1){
						_x.show_alert_submit(res.data.msg,true)
					}else{
						_x.show_alert_submit(res.data.msg,false)
					}
				})
				.catch(function(){
					$btn.button('reset')
					_x.show_alert_submit("提交失败，请稍后重试！",false)
				})
			}
		})
		
		function yanzheng2(yzDoms){
			var errDom = null;
			yzDoms.each(function(){
				var that = $(this),
					val = that.val();
				if(_x.isEmpty(val)){//空判断
					that.attr("placeholder","此项不能为空！");
					that.parents(".form-group").addClass("has-error");
					if(errDom === null)errDom = that
				}else if(!_x.isEmpty(that.data("len")) && val.length != that.data("len")){
					that.attr("placeholder","长度必须为"+ that.data("len") +"位");
					that.parents(".form-group").addClass("has-error");
					if(errDom === null)errDom = that
				}else if(that.hasClass("number") && isNaN(+val)){
					that.attr("placeholder","请输入数字！");
					that.parents(".form-group").addClass("has-error");
					if(errDom === null)errDom = that
				}else if((that.hasClass("precitysel") && val == -1) || (that.hasClass("precitysel") && that.siblings(".precitysel").val() == -1)){
					//判断是否选择省市
					that.parents(".form-group").addClass("has-error");
					if(errDom === null)errDom = that
				}else{
					that.parents(".form-group").removeClass("has-error");
				}
			})
			return errDom;
		}
		
		//视频上传
		/* $('#gitsp').click(function(){
			
		}) */
		 $("#datalist").on('change','#gitsp',function(){ 
			/* $('#gitsp').change(function(){ */
			var fileVal = $(this).val();
			var fileName = fileVal.substring(fileVal.lastIndexOf("\\")+1);//视频名字
			var files = this.files,
	            video = $('#video').find('video'),
	            videoURL = null,
	            windowURL = window.URL || window.webkitURL;
			
			if (files && files[0]) {

                videoURL = windowURL.createObjectURL(files[0]);
                var videoHTML= '';
                videoHTML += `
                	<video src="${videoURL}" controls="controls" width='300' height='200'></video>
                	<p width='300px' style='text-align:center;'>${fileName}</P>
                `
                $('#video').html(videoHTML);

            }
			var options = { 
					beforeSubmit:function(formData, jqForm, options){
						console.log(formData);
					},
					success: function(data,status){
						console.log(data);
						console.log(status);
					}
			}
			
			$('#spFrom').ajaxSubmit(options);
			
		}).trigger('change');
		

		
	})
</script>
#end
